package com.gw.vip.server.service;

import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @author GW
 * @description 异步余额语音播报
 * @since 2022-08-06
 */
@Service
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class VoiceService {
    private final Dispatch dispatch;

    /**
     * 播报余额
     * @param bal
     */
    @Async
    public void broadcastBalance(BigDecimal bal){
        String str = "余额"+bal+"元";
        // 执行朗读
        Dispatch.call(dispatch, "Speak", new Variant(str));
    }
}
